package wps.component.elementsetting {
import flash.geom.Matrix;
import flash.geom.Point;

import mx.core.UIComponent;

import wps.component.DrawingImage;
import wps.component.IDrawingElement;
import wps.util.GeomUtil;
import wps.util.StringUtils;

/**
 * 输入旋转的角度
 */
public class RotationSettingTextInput extends SettingTextInput {

    override protected function textSetter(value:Object):void {
        if (target && targetProperty) {
            // 角度只显示整数
            var num:Number = target[targetProperty];
            text = Math.round(num).toString();
        } else {
            text = "";
        }
    }

    override protected function inputCompleted():void {
        if (!target || StringUtils.isBlank(text)) {
            return;
        }

        var angle:Number = Number(text) - target.rotation;
        if (angle != 0) {
            GeomUtil.rotate(UIComponent(target), angle);

            var element:IDrawingElement = target as IDrawingElement;
            element.elementRotation = target.rotation;
        }
    }

}
}
